﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;


namespace MDA
{



    /// <summary>
    /// 登录访问日志处理。

    /// </summary>
    public class LogRule
    {
        public LogRule()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }
        /// <summary>
        /// 第一次登录时记录登录日志。

        /// </summary>
        /// <param name="logname">登录名</param>
        /// <param name="loginip">登录IP</param>
        /// <param name="remark">备注</param>
        public void LoginLog(string logname, string loginip)
        {
            T_LOG_MOSTLYData data = new T_LOG_MOSTLYData();
            data.USERNAME = logname;
            data.LOGINTIME = DateTime.Now;
            data.LOGINIP = loginip;
            data.REMARK = "登录";
            T_LOG_MOSTLYAccess ac = new T_LOG_MOSTLYAccess();
            ac.Insert_I(data);
            CurrentUser cu = new CurrentUser();
            cu.LogId = data.SEQ.ToString();
        }

        /// <summary>
        /// 用户离开时记录日志

        /// </summary>
        /// <param name="logname">登录用户名</param>
        public void LogoutLog(string logname)
        {
            CurrentUser cu = new CurrentUser();
            T_LOG_MOSTLYData data = new T_LOG_MOSTLYData();
            data.SEQ = int.Parse(cu.LogId);
            T_LOG_MOSTLYAccess ac = new T_LOG_MOSTLYAccess();
            ac.Select(data);
            data.LOGOUTTIME = DateTime.Now;
            data.REMARK = "离开";
            ac.Update(data);
        }

        /// <summary>
        /// 用户访问某页面时记录详细日志
        ///// </summary>
        //public void VisitPage()
        //{
        //    T_LOG_DETAILSData data = new T_LOG_DETAILSData();
        //    CurrentUser cu = new CurrentUser();
        //    data.MENUID = cu.MENU.MENUID;
        //    data.LOGID = int.Parse(cu.LogId);
        //    data.OPERATETIME = DateTime.Now;
        //    T_LOG_DETAILSAccess ac = new T_LOG_DETAILSAccess();
        //    ac.Insert(data);
        //}
    }
}